<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学员</title>
</head>
<body>
<form id="de-add-dlg-form" action="StudentServlet.do?method=add"
		method="post">
		 <input type="hidden" name="id">
		<div class="datagrid-body">
			<table class="datagrid-btable" cellspacing="0" cellpadding="0"
				border="0" style="width: 100%;">
<!-- 				 style="height: 80%;" -->
				<tbody>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">姓名</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="name"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">身份证号</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="idNumber"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">性别</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							
							<div>
							<input name="sex" type="radio" checked="checked"  value='男'>男
                      		<input name="sex" type="radio"  value='女'>女
                      		</div> 
<!-- 							class="easyui-validatebox" style="width: 266px"> -->
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">年龄</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="age"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">手机号</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="phone"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">报考车型</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
						<div class="changeDiv">
					        <select name="candiCar" style="width: 80px">
					        	<option value="C1" selected="selected">C1</option>
					        	<option value="C2">C2</option>
					        	<option value="B1">B1</option>
					        	<option value="B2">B2</option>
					        	<option value="A1">A1</option>
					        	<option value="A2">A2</option>
					        </select>
					    </div>
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">学费</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="learnSalary"
							class="easyui-validatebox" style="width: 266px" value="5000">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">户籍</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="censusRegister"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					<tr class="datagrid-row">
						<td
							style="border-style: solid; width: 15%; text-align: right; padding-right: 7px">住址</td>
						<td style="border-style: solid; width: 35%; text-align: left;">
							<input type="text" name="address"
							class="easyui-validatebox" style="width: 266px">
						</td>
					</tr>
					
				
				</tbody>
			</table>
		</div>
	</form>
<script type="text/javascript">
	$(function(){
		debugger;
		//失去焦点触发 
		$("#de-add-dlg-form input[name='idNumber']").blur(function(){
			var $idNumber =$("#de-add-dlg-form input[name='idNumber']").val();
			debugger;
			$("#de-add-dlg-form input[name='sex'][value='"+getSex($idNumber)+"']").prop("checked","checked");
			$("#de-add-dlg-form input[name='age']").val(getAge($idNumber));
		});
		//失去焦点触发 
		$("#de-add-dlg-form select[name='candiCar']").change(function(){
			var $learnSalary = $("#de-add-dlg-form input[name='learnSalary']");
			
			var candicarValue = $("#de-add-dlg-form select[name='candiCar']").val();
			if(candicarValue=='A1'){
				$learnSalary.val(30000);
			}else if(candicarValue=='A2'){
				$learnSalary.val(20000);
			}else if(candicarValue=='C1'){
				$learnSalary.val(5000);
			}else if(candicarValue=='C2'){
				$learnSalary.val(5500);
			}else if(candicarValue=='B1'){
				$learnSalary.val(6000);
			}else if(candicarValue=='B2'){
				$learnSalary.val(8000);
			}
		});
		$("#de-add-dlg-form .easyui-validatebox").validatebox({
	            required:true,
	            novalidate:true
	        }).focus(function(){
	            $(this).validatebox({novalidate:false});
	        }).blur(function(){
	        	$(this).validatebox({novalidate:false});
	    });
	});
	function getSex(UUserCard){
		if (UUserCard) {
			try{
	            //获取性别
	            if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
	                //男
	                return "男";
	            } else {
	                //女
	                return "女";
	            }
			}catch (e) {
				return "男";
			}
	    }
	}
	function getAge(UUserCard){
		try{
			if (UUserCard) {
				//获取年龄
				var myDate = new Date();
				var month = myDate.getMonth() + 1;
				var day = myDate.getDate();
				var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
				if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
				    age++;
				}
				return age;
			}
		}catch (e) {
			return "";
		}
	}
</script>	
</body>
</html>